package com.apartment.common.utils.reflection;


import com.apartment.common.utils.StringUtils;

import java.util.regex.Pattern;

/**
 * @program: cct
 * @description: 手机号java校验
 * @author: @Dog_E
 * @create: 2020-05-05 13:39
 **/
public class MobilePhoneNumberUtil {
    private static final String REGEX_MOBILE ="((\\+86|0086)?\\s*)((134[0-8]\\d{7})|(((13([0-3]|[5-9]))|(14[5-9])|15([0-3]|[5-9])|(16(2|[5-7]))|17([0-3]|[5-8])|18[0-9]|19(1|[8-9]))\\d{8})|(14(0|1|4)0\\d{7})|(1740([0-5]|[6-9]|[10-12])\\d{7}))";

    /**
     * 判断是否是手机号
     * @param tel 手机号
     * @return boolean true:是  false:否
     */
    public static boolean isMobile(String tel) {
        if (StringUtils.isEmpty(tel)){ return false;}
        return Pattern.matches(REGEX_MOBILE, tel);
    }

    public static void main(String[] args) {
        boolean mobile = isMobile("13298133559");
        boolean mobile2 = isMobile("1329813355");
        boolean mobile3 = isMobile("11298133559");
        System.out.println(mobile);
        System.out.println(mobile2);
        System.out.println(mobile3);
    }
}
